package com.pets.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.pets.entity.LanguageType;
import com.pets.entity.Users;
import com.pets.mapper.LanguageTypeMapper;
import com.pets.service.ILanguageTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pets.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 语言标签类型 服务实现类
 * </p>
 *
 * @author 啦啦啦
 * @since 2024-04-11
 */
@Service
public class LanguageTypeServiceImpl extends ServiceImpl<LanguageTypeMapper, LanguageType> implements ILanguageTypeService {

    @Autowired
    private LanguageTypeMapper languageTypeMapper;

    @Override
    public Result register(LanguageType languageType) {
        return languageTypeMapper.insert(languageType)>0?Result.success("成功！"):Result.fail("失败！");
    }

    @Override
    public Result deleteById(Integer id) {
        return languageTypeMapper.deleteById(id)>0?Result.success("成功！"):Result.fail("失败！");
    }

    @Override
    public Result updateData(LanguageType languageType) {
        return languageTypeMapper.updateById(languageType)>0?Result.success("成功！"):Result.fail("失败！");
    }

    @Override
    public Result selectList(String languageTypeName) {
        final LambdaQueryWrapper<LanguageType> lqw = new LambdaQueryWrapper<>();
        lqw.like(languageTypeName!=null&&!languageTypeName.isEmpty(),LanguageType::getLanguageTypeName,languageTypeName);
        List<LanguageType> languageTypes = languageTypeMapper.selectList(lqw);
        return Result.success("成功！",languageTypes);
    }
}
